<template>
    <h2>用户赎回界面</h2>
    <table>
        <tr>
            <td>项目名称</td>
            <td>
                <input type="text" v-model="I_Name">
            </td>
        </tr>
        <tr>
            <td>理财总金额</td>
            <td>
                <input type="text" v-model="I_Mon">
            </td>
        </tr>
        <tr>
            <td>用户理财金额</td>
            <td>
                <input type="text" v-model="V_Money">
            </td>
        </tr>
        <tr>
            <td>赎回金额</td>
            <td>
                <input type="text" v-model="M_Money">
            </td>
        </tr>
        <tr>
            <td></td>
            <td>
                <input type="button" value="我要赎回" @click="Manage">
            </td>
        </tr>

    </table>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import axios from 'axios';
import { onMounted } from 'vue';
import { useRoute } from 'vue-router';
const route = useRoute();
const I_Name = ref('');
const I_Mon = ref('');
const V_Money = ref('');
const I_Id = route.params.I_Id;

onMounted(() => {
    axios.get('http://localhost:25825/api/Demo/Fan', {
        params: {
            I_Id: I_Id
        }
    })
        .then(res => {
            I_Name.value = res.data[0].I_Name
            I_Mon.value = res.data[0].I_Mon
            V_Money.value = res.data[0].V_Money
        })
})
const M_Money = ref();
const Manage = () => {
    if (M_Money.value <= 0) {
        alert("赎回金额不能小于0");
        return;
    }
    if (M_Money.value > V_Money.value) {
        alert("赎回金额不能大于理财金额");
        return;
    }

}
</script>